home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / p_man / cat3s / fread.z / fread
Text File  |  1998-10-20  |  5KB  |  133 lines

  1.  
  2.  
  3.  
  4. FFFFRRRREEEEAAAADDDD((((3333SSSS))))                                                            FFFFRRRREEEEAAAADDDD((((3333SSSS))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      fread, fwrite - binary input/output
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddiiiioooo....hhhh>>>>
  13.  
  14.      ssssiiiizzzzeeee____tttt ffffrrrreeeeaaaadddd ((((vvvvooooiiiidddd ****ppppttttrrrr,,,, ssssiiiizzzzeeee____tttt ssssiiiizzzzeeee,,,, ssssiiiizzzzeeee____tttt nnnniiiitttteeeemmmmssss,,,, FFFFIIIILLLLEEEE ****ssssttttrrrreeeeaaaammmm))));;;;
  15.  
  16.      ssssiiiizzzzeeee____tttt ffffwwwwrrrriiiitttteeee ((((ccccoooonnnnsssstttt vvvvooooiiiidddd ****ppppttttrrrr,,,, ssssiiiizzzzeeee____tttt ssssiiiizzzzeeee,,,, ssssiiiizzzzeeee____tttt nnnniiiitttteeeemmmmssss,,,, FFFFIIIILLLLEEEE
  17.      ****ssssttttrrrreeeeaaaammmm))));;;;
  18.  
  19. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  20.      _f_r_e_a_d copies, into an array pointed to by _p_t_r, up to _n_i_t_e_m_s items of data
  21.      from the named input _s_t_r_e_a_m, where an item of data is a sequence of bytes
  22.      (not necessarily terminated by a null byte) of length _s_i_z_e.  _f_r_e_a_d stops
  23.      reading bytes if an end-of-file or error condition is encountered while
  24.      reading _s_t_r_e_a_m, or if _n_i_t_e_m_s items have been read.  The file pointer
  25.      associated with _s_t_r_e_a_m is positioned following the last byte read, which
  26.      may be at end-of-file.  _f_r_e_a_d does not change the contents of _s_t_r_e_a_m.
  27.      _f_r_e_a_d returns the number of items read.
  28.  
  29.      _f_w_r_i_t_e appends at most _n_i_t_e_m_s items of data from the array pointed to by
  30.      _p_t_r to the named output _s_t_r_e_a_m.  _f_w_r_i_t_e stops appending when it has
  31.      appended _n_i_t_e_m_s items of data or if an error condition is encountered on
  32.      _s_t_r_e_a_m.  _f_w_r_i_t_e does not change the contents of the array pointed to by
  33.      _p_t_r.  _f_w_r_i_t_e increments the data-printer in the stream by the number of
  34.      bytes written.  _f_w_r_i_t_e returns the number of items written.
  35.  
  36.      _f_e_r_r_o_r(_3_S) may be used to determine if an error occurred in an _f_r_e_a_d or
  37.      _f_w_r_i_t_e call.  The _f_e_r_r_o_r(_3_S) or _f_e_o_f(_3_S) routines should be used to
  38.      distinguish between an error condition and end-of-file condition.
  39.  
  40.      The argument _s_i_z_e is typically _s_i_z_e_o_f(*_p_t_r) where the C operator _s_i_z_e_o_f
  41.      is used to determine the length of an item pointed to by _p_t_r.
  42.  
  43. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  44.      exit(2), fcntl(2), lseek(2), read(2), write(2), abort(3C), fclose(3S),
  45.      fopen(3S), ferror(3S), getc(3S), gets(3S), printf(3S), putc(3S),
  46.      puts(3S), scanf(3S), stdio(3S).
  47.  
  48. NNNNOOOOTTTTEEEE
  49.      To use these functions with direct I/O (see _f_c_n_t_l(2)), it is necessary to
  50.      arrange that the buffers be correctly aligned before any I/O is done.
  51.      One way to do this is:
  52.  
  53.           char *caBuffer11;
  54.           caBuffer11 = memalign(dioinfo.d_mem, 8+100 * dioinfo.d_miniosz);
  55.           setbuffer(fpOutFile,caBuffer11,8+100 * dioinfo.d_miniosz);
  56.  
  57.      where the _d_i_o_i_n_f_o structure has been filled in by the FFFF____DDDDIIIIOOOOIIIINNNNFFFFOOOO _f_c_n_t_l
  58.      request.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. FFFFRRRREEEEAAAADDDD((((3333SSSS))))                                                            FFFFRRRREEEEAAAADDDD((((3333SSSS))))
  71.  
  72.  
  73.  
  74. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  75.      Both _f_r_e_a_d and _f_w_r_i_t_e always return a nonnegative integer indicating the
  76.      number of items read or written.  This will be equal to _n_i_t_e_m_s unless an
  77.      error occurred, the value of _s_i_z_e is zero, or _f_r_e_a_d or _f_w_r_i_t_e detect that
  78.      a request has been made to read (or write) more data than is addressable.
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.